home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / CMCD1104.ISO / Software / Freeware / Grafica / galeroo / Setup Galleroo 3.4.exe / {app} / styles / Lib / galleroo.xsl
Extensible Markup Language  |  2004-09-20  |  37KB  |  817 lines

  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:exsl="http://exslt.org/common" 
  4.                 xmlns:func="http://exslt.org/functions"
  5.                 xmlns:galleroo="."
  6.                 extension-element-prefixes="func galleroo exsl" 
  7.                 version='1.1'>
  8.                 
  9. <!-- Galleroo stylesheet library 1.5
  10.      Copyright 2003-2004, all rights reserved, xyster.net
  11.      written: 
  12.      modified:
  13.      author:    xyster                
  14. -->     
  15.  
  16. <!-- need this guy so we can access general lister info outside of
  17.      the scope of queries we will be called on 
  18. -->     
  19. <xsl:variable name="source-root" select="/" />
  20.  
  21. <!-- sort images using the attribute named in sort-by -->
  22. <func:function name="galleroo:sort-pix">
  23.     <xsl:param name="pix" />
  24.     <xsl:param name="sort-by" />
  25.     
  26.     <xsl:variable name="sorted-pix">
  27.         <xsl:for-each select="$pix">
  28.             <xsl:sort select="attrib/*[name()=$sort-by]" />
  29.             <xsl:copy-of select="." />
  30.         </xsl:for-each>
  31.     </xsl:variable>
  32.     
  33.     <func:result select="$sorted-pix" />
  34. </func:function>
  35.  
  36. <!-- function to trim everything after a period (.). Makes for pretty filenames -->
  37. <func:function name="galleroo:pretty-name">
  38.     <xsl:param name="name" />
  39.     <func:result select="concat(substring($name, 1, string-length($name) - 6),
  40.                                 substring-before(substring($name, string-length($name) - 5, 5), '.'))" />
  41. </func:function>
  42.  
  43. <func:function name="galleroo:index-html-name">
  44.     <xsl:param name="index" />
  45.     <xsl:choose>
  46.         <xsl:when test="$index = 1">
  47.             <func:result>index.html</func:result>
  48.         </xsl:when>
  49.         <xsl:otherwise>
  50.             <func:result>index<xsl:value-of select="$index" />.html</func:result>
  51.         </xsl:otherwise>
  52.     </xsl:choose>
  53. </func:function>    
  54.  
  55. <func:function name="galleroo:image-title">
  56.     <xsl:param name="attrib" />
  57.     <xsl:choose> 
  58.         <xsl:when test="$attrib/user-title != ''">
  59.             <func:result select="$attrib/user-title" />
  60.         </xsl:when>
  61.         <xsl:when test="galleroo:iptc($attrib, 'title') != ''">
  62.             <func:result select="galleroo:iptc($attrib, 'title')" />
  63.         </xsl:when>
  64.         <xsl:otherwise>
  65.             <func:result select="galleroo:pretty-name($attrib/name)" />
  66.         </xsl:otherwise>
  67.     </xsl:choose>
  68. </func:function>
  69.  
  70. <func:function name="galleroo:image-caption">
  71.     <xsl:param name="attrib" />
  72.     <xsl:choose>
  73.         <xsl:when test="$attrib/user-caption != ''">
  74.             <func:result> - <xsl:value-of select="$attrib/user-caption" /></func:result>
  75.         </xsl:when>
  76.         <xsl:when test="galleroo:iptc($attrib, 'caption') != ''">
  77.             <func:result> - <xsl:value-of select="galleroo:iptc($attrib, 'caption')" /></func:result>
  78.         </xsl:when>
  79.         <xsl:otherwise>
  80.             <func:result select="''" />
  81.         </xsl:otherwise>
  82.     </xsl:choose>
  83. </func:function>
  84.  
  85. <func:function name="galleroo:image-comment">
  86.     <xsl:param name="attrib" />
  87.     <xsl:choose>
  88.         <xsl:when test="$attrib/user-comment != ''">
  89.             <func:result select="$attrib/user-comment" />
  90.         </xsl:when>
  91.         <xsl:when test="galleroo:iptc($attrib, 'comment') != ''">
  92.             <func:result select="galleroo:iptc($attrib, 'comment')" />
  93.         </xsl:when>
  94.         <xsl:otherwise>
  95.             <func:result select="$attrib/comment" />
  96.         </xsl:otherwise>
  97.     </xsl:choose>
  98. </func:function>
  99.  
  100.  
  101. <!-- gets the next image in the list -->
  102. <func:function name="galleroo:next-image">
  103.     <func:result select="following-sibling::object[position() = 1]" />
  104. </func:function>
  105.  
  106. <!-- gets the previous image in the list -->
  107. <func:function name="galleroo:previous-image">
  108.     <func:result select="preceding-sibling::object[position() = 1]" />
  109. </func:function>
  110.  
  111. <func:function name="galleroo:iptc-num">
  112.     <xsl:param name="iname" />
  113.     
  114.     <xsl:variable name="xtab">
  115.         <a><name>unknown0</name><num>00</num></a>
  116.         <a><name>title</name><num>05</num></a>
  117.         <a><name>urgency</name><num>0a</num></a>
  118.         <a><name>categories</name><num>14</num></a>
  119.         <a><name>keywords</name><num>19</num></a>
  120.         <a><name>instructions</name><num>28</num></a>
  121.         <a><name>date</name><num>37</num></a>
  122.         <a><name>author</name><num>50</num></a>
  123.         <a><name>author-position</name><num>55</num></a>
  124.         <a><name>city</name><num>5a</num></a>
  125.         <a><name>state</name><num>5f</num></a>
  126.         <a><name>country-code</name><num>64</num></a>
  127.         <a><name>country</name><num>65</num></a>
  128.         <a><name>trans-ref</name><num>67</num></a>
  129.         <a><name>headline</name><num>69</num></a>
  130.         <a><name>credit</name><num>6e</num></a>
  131.         <a><name>source</name><num>73</num></a>
  132.         <a><name>copyright</name><num>74</num></a>
  133.         <a><name>caption</name><num>78</num></a>
  134.         <a><name>caption-author</name><num>7a</num></a>
  135.     </xsl:variable>
  136.     
  137.     <xsl:choose>
  138.         <xsl:when test="substring($iname, 1, 5) = 'iptc-'">
  139.             <xsl:variable name="jname" select="substring-after($iname, 'iptc-')" />
  140.             <func:result select="concat('iptc-', exsl:node-set($xtab)/a[name = $jname]/num)" />        
  141.         </xsl:when>
  142.         <xsl:otherwise>
  143.             <func:result select="concat('iptc-', exsl:node-set($xtab)/a[name = $iname]/num)" />
  144.         </xsl:otherwise>    
  145.     </xsl:choose>
  146. </func:function>    
  147.  
  148. <func:function name="galleroo:iptc">
  149.     <xsl:param name="attrib" />
  150.     <xsl:param name="name" />
  151.  
  152.     <func:result select="$attrib/*[name() = galleroo:iptc-num($name)]" />
  153. </func:function>    
  154.  
  155. <func:function name="galleroo:rplstr">
  156.     <xsl:param name="value" />
  157.     <xsl:param name="from" />
  158.     <xsl:param name="to" />
  159.     
  160.     <func:result><xsl:call-template name="gal-rplstr"><xsl:with-param name="value" select="$value" /><xsl:with-param name="from" select="$from" /><xsl:with-param name="to" select="$to" /></xsl:call-template></func:result>
  161. </func:function>
  162.  
  163. <xsl:template name="gal-emit-css-file">
  164.     <xsl:param name="name" />
  165.     <xsl:param name="html-file-prefix" />
  166.     <xsl:param name="background-image" />
  167.     <xsl:param name="background-color" />
  168.     <xsl:param name="font" />
  169.     <xsl:param name="text-color" />
  170.     <xsl:param name="link-color" />
  171.     <xsl:param name="active-link-color" />
  172.     <xsl:param name="visited-link-color" />
  173.    
  174.     <!-- leave room for post creation, user customization -->
  175.     @import url("base.css");
  176.     body 
  177.      {
  178.       <xsl:call-template name="gal-emit-css-attribute">
  179.          <xsl:with-param name="name" select="'background-image'" />
  180.          <xsl:with-param name="value" select="$background-image" />
  181.          <xsl:with-param name="type" select="'url'" />
  182.       </xsl:call-template>
  183.       
  184.       <xsl:call-template name="gal-emit-css-attribute">
  185.          <xsl:with-param name="name" select="'background-color'" />
  186.          <xsl:with-param name="value" select="$background-color" />
  187.       </xsl:call-template>
  188.         
  189.       <xsl:call-template name="gal-emit-css-attribute">
  190.          <xsl:with-param name="name" select="'color'" />
  191.          <xsl:with-param name="value" select="$text-color" />
  192.       </xsl:call-template>
  193.  
  194.       <xsl:call-template name="gal-emit-css-font-attributes">
  195.          <xsl:with-param name="font" select="$font" />
  196.       </xsl:call-template>  
  197.      }
  198.      
  199.     a 
  200.      {
  201.       <xsl:call-template name="gal-emit-css-attribute">
  202.          <xsl:with-param name="name" select="'color'" />
  203.          <xsl:with-param name="value" select="$link-color" />
  204.       </xsl:call-template>
  205.      }     
  206.     
  207.     a:visited 
  208.      {
  209.       <xsl:call-template name="gal-emit-css-attribute">
  210.          <xsl:with-param name="name" select="'color'" />
  211.          <xsl:with-param name="value" select="$visited-link-color" />
  212.       </xsl:call-template>
  213.      }
  214.     
  215.     a:active 
  216.      {
  217.       <xsl:call-template name="gal-emit-css-attribute">
  218.          <xsl:with-param name="name" select="'color'" />
  219.          <xsl:with-param name="value" select="$active-link-color" />
  220.       </xsl:call-template>
  221.      }  
  222.  
  223.     a:hover 
  224.      {
  225.       <xsl:call-template name="gal-emit-css-attribute">
  226.          <xsl:with-param name="name" select="'color'" />
  227.          <xsl:with-param name="value" select="$active-link-color" />
  228.       </xsl:call-template>
  229.      }
  230.  
  231.     <!-- cutter output -->
  232.     <xsl:text> </xsl:text>
  233.     <xsl:comment>CUTHERE: <xsl:value-of select="galleroo:rplstr(concat($html-file-prefix, $name), '-', '\-')" />.css ?</xsl:comment>
  234.     <xsl:text> </xsl:text>
  235.  
  236.     
  237. </xsl:template>
  238.  
  239. <xsl:template name="gal-emit-css-attribute">
  240.     <xsl:param name="name" />
  241.     <xsl:param name="value" />
  242.     <xsl:param name="type" />
  243.     
  244.     <xsl:if test="string-length($value) != 0">
  245.         <xsl:choose>
  246.             <xsl:when test="$type = 'url'">
  247.                 <xsl:value-of select="$name" />: url(<xsl:value-of select="$value" />);
  248.             </xsl:when>
  249.             <xsl:otherwise>
  250.                 <xsl:value-of select="$name" />: <xsl:value-of select="$value" />;
  251.             </xsl:otherwise>
  252.         </xsl:choose>
  253.     </xsl:if>
  254.     
  255. </xsl:template>
  256.  
  257. <!-- line-through underline italic bold 14pt "Comic Sans MS", fantasy -->
  258. <xsl:template name="gal-emit-css-font-attributes">
  259.     <xsl:param name="font" />
  260.     
  261.     <xsl:if test="string-length($font) != 0">
  262.         <xsl:variable name="first-attribute" select="substring-before($font, ' ')" />
  263.         <xsl:variable name="second-attribute" select="substring-before(substring-after($font, concat($first-attribute, ' ')), ' ')" />
  264.         
  265.         <xsl:choose>
  266.             <xsl:when test="$first-attribute = 'underline'">
  267.                 <xsl:call-template name="gal-emit-css-attribute">
  268.                     <xsl:with-param name="name" select="'text-decoration'" />
  269.                     <xsl:with-param name="value" select="$first-attribute" />
  270.                 </xsl:call-template>
  271.                 <xsl:call-template name="gal-emit-css-attribute">
  272.                     <xsl:with-param name="name" select="'font'" />
  273.                     <xsl:with-param name="value" select="substring-after($font, $first-attribute)" />
  274.                 </xsl:call-template>
  275.             </xsl:when>
  276.             <xsl:when test="$first-attribute = 'line-through'">
  277.                 <xsl:choose>
  278.                     <xsl:when test="$second-attribute = 'underline'">
  279.                         <xsl:call-template name="gal-emit-css-attribute">
  280.                             <xsl:with-param name="name" select="'text-decoration'" />
  281.                             <xsl:with-param name="value" select="concat($first-attribute, ' ', $second-attribute)" />    
  282.                         </xsl:call-template>
  283.                         <xsl:call-template name="gal-emit-css-attribute">
  284.                             <xsl:with-param name="name" select="'font'" />
  285.                             <xsl:with-param name="value" select="substring-after($font, $second-attribute)" />
  286.                         </xsl:call-template>
  287.                     </xsl:when>
  288.                     <xsl:otherwise>
  289.                         <xsl:call-template name="gal-emit-css-attribute">
  290.                             <xsl:with-param name="name" select="'text-decoration'" />
  291.                             <xsl:with-param name="value" select="$first-attribute" />
  292.                         </xsl:call-template>
  293.                         <xsl:call-template name="gal-emit-css-attribute">
  294.                             <xsl:with-param name="name" select="'font'" />
  295.                             <xsl:with-param name="value" select="substring-after($font, $first-attribute)" />
  296.                         </xsl:call-template>
  297.                     </xsl:otherwise> 
  298.                 </xsl:choose>
  299.             </xsl:when>
  300.             <xsl:otherwise>
  301.                 <xsl:call-template name="gal-emit-css-attribute">
  302.                     <xsl:with-param name="name" select="'font'" />
  303.                     <xsl:with-param name="value" select="$font" />
  304.                 </xsl:call-template>
  305.             </xsl:otherwise>
  306.         </xsl:choose>
  307.     </xsl:if>
  308. </xsl:template>
  309.  
  310. <!-- Emit simple navbar/slide based frameset
  311. -->     
  312.  
  313. <xsl:template name="gal-emit-frameset">
  314.     <xsl:param name="preview" />
  315.     <xsl:param name="title" />
  316.     <xsl:param name="sub-title" />
  317.     <xsl:param name="nav-alignment" />
  318.     <xsl:param name="sort-by" />
  319.     <xsl:param name="thumb-size" />
  320.     <xsl:param name="padding" />
  321.     <xsl:param name="html-file-prefix" />
  322.     
  323.      <!-- frameset -->
  324.        <html>
  325.     <head>
  326.         <title><xsl:value-of select="$title" /> - <xsl:value-of select="$sub-title" /></title>
  327.     </head>
  328.  
  329.     <xsl:choose>
  330.         <xsl:when test="$nav-alignment = 'left'">
  331.             <frameset cols="{$thumb-size + $padding},*" frameborder="yes" border="0" framespacing="0"> 
  332.                 <frame name="navFrame" scrolling="yes" noresize="1" src="{$html-file-prefix}nav.html" />
  333.                 <xsl:call-template name="gal-emit-initial-slide-frame">
  334.                     <xsl:with-param name="preview" select="$preview" />
  335.                     <xsl:with-param name="sort-by" select="$sort-by" />
  336.                     <xsl:with-param name="html-file-prefix" select="$html-file-prefix" />
  337.                 </xsl:call-template>    
  338.             </frameset>
  339.         </xsl:when>
  340.         <xsl:when test="$nav-alignment = 'top'">
  341.             <frameset rows="{$thumb-size + $padding},*" frameborder="yes" border="0" framespacing="0"> 
  342.                 <frame name="navFrame" scrolling="yes" noresize="1" src="{$html-file-prefix}nav.html" />
  343.                 <xsl:call-template name="gal-emit-initial-slide-frame">
  344.                     <xsl:with-param name="preview" select="$preview" />
  345.                     <xsl:with-param name="sort-by" select="$sort-by" />
  346.                     <xsl:with-param name="html-file-prefix" select="$html-file-prefix" />
  347.                 </xsl:call-template>    
  348.             </frameset>
  349.         </xsl:when>
  350.         <xsl:when test="$nav-alignment = 'right'">
  351.             <frameset cols="*, {$thumb-size + $padding}" frameborder="yes" border="0" framespacing="0"> 
  352.                 <xsl:call-template name="gal-emit-initial-slide-frame">
  353.                     <xsl:with-param name="preview" select="$preview" />
  354.                     <xsl:with-param name="sort-by" select="$sort-by" />
  355.                     <xsl:with-param name="html-file-prefix" select="$html-file-prefix" />
  356.                 </xsl:call-template>    
  357.                 <frame name="navFrame" scrolling="yes" noresize="1" src="{$html-file-prefix}nav.html" />
  358.             </frameset>
  359.         </xsl:when>
  360.         <xsl:when test="$nav-alignment = 'bottom'">
  361.             <frameset rows="*, {$thumb-size + $padding}" frameborder="yes" border="0" framespacing="0"> 
  362.                 <xsl:call-template name="gal-emit-initial-slide-frame">
  363.                     <xsl:with-param name="preview" select="$preview" />
  364.                     <xsl:with-param name="sort-by" select="$sort-by" />
  365.                     <xsl:with-param name="html-file-prefix" select="$html-file-prefix" />
  366.                 </xsl:call-template>    
  367.                 <frame name="navFrame" scrolling="yes" noresize="1" src="{$html-file-prefix}nav.html" />
  368.             </frameset>        
  369.         </xsl:when>
  370.     </xsl:choose>
  371.  
  372.     <noframes>
  373.     <body class="noframe-page">
  374.         You need a web browser that supports frames to view this photo gallery.
  375.     </body>
  376.     </noframes>
  377.     </html>
  378.     
  379.     <!-- cutter output -->
  380.     <xsl:call-template name="gal-emit-cutter-index">
  381.         <xsl:with-param name="index" select="1" />
  382.         <xsl:with-param name="html-file-prefix" select="$html-file-prefix" />
  383.     </xsl:call-template>
  384. </xsl:template>
  385.  
  386. <xsl:template name="gal-emit-initial-slide-frame">
  387.     <xsl:param name="preview" />
  388.     <xsl:param name="sort-by" />
  389.     <xsl:param name="html-file-prefix" />
  390.  
  391.     <xsl:choose>
  392.     <xsl:when test="$preview = 0">
  393.         <frame name="main" src="{$html-file-prefix}blank.html" />
  394.     </xsl:when>
  395.     <xsl:otherwise>
  396.         <xsl:variable name="sorted-pix" select="galleroo:sort-pix($source-root/list/media/object/children/object/children/object, $sort-by)" />
  397.         <frame name="main" src="{$html-file-prefix}{exsl:node-set($sorted-pix)/*[1]/attrib/name}.html" />
  398.     </xsl:otherwise>
  399.     </xsl:choose>
  400. </xsl:template>
  401.  
  402. <!-- Navigation Bar -->
  403. <xsl:template name="gal-emit-nav-bar">
  404.     <xsl:param name="alignment" />
  405.     <xsl:param name="sort-by" />
  406.     <xsl:param name="css-name" />
  407.     <xsl:param name="custom-css-file" />
  408.     <xsl:param name="html-file-prefix" />
  409.     
  410.     <html>
  411.     <head>
  412.         <link type="text/css" rel="stylesheet" href="{$html-file-prefix}{$css-name}.css" />
  413.         <xsl:if test="string-length($custom-css-file) != 0">
  414.             <link type="text/css" rel="stylesheet" href="{$custom-css-file}" />
  415.         </xsl:if>    
  416.         <title>Galleroo Nav Bar</title>
  417.     </head>
  418.     <body class="index-page">
  419.     
  420.     <xsl:choose>
  421.     
  422.     <!-- vertical nav bar -->
  423.     <xsl:when test="$alignment = 'left' or $alignment = 'right'">
  424.         <!-- home link -->
  425.         <div align="center">
  426.             <a href="../index.html" target="_top">Home</a>
  427.         </div>
  428.     
  429.         <div align="center">
  430.             <table class="thumb-table" align="center" border="0">
  431.              <xsl:for-each select="media/object/children/object/children/object">
  432.                 <xsl:sort select="attrib/*[name()=$sort-by]" />
  433.                 <tr>
  434.                     <td align="center"><a target="main" href="{$html-file-prefix}{attrib/name}.html"><img class="thumb" width="{attrib/thumb-x-size}" height="{attrib/thumb-y-size}" src="{attrib/thumb-path}/{attrib/thumb-name}" border="0" /></a></td>
  435.                 </tr>
  436.                 <tr>
  437.                     <td align="center"><a target="main" href="{$html-file-prefix}{attrib/name}.html"><xsl:value-of select="galleroo:image-title(attrib)" /></a></td>
  438.                    </tr>
  439.                </xsl:for-each>
  440.             </table>
  441.         </div>
  442.     </xsl:when>
  443.     
  444.     <!-- horizontal nav bar -->
  445.     <xsl:otherwise>
  446.         <!-- home link -->
  447.         <div align="left">
  448.             <a href="../index.html" target="_top">Home</a>
  449.         </div>
  450.     
  451.         <!-- thumbnails -->
  452.         <div align="center">
  453.             <table class="thumb-table" align="center" border="0">
  454.              <tr>
  455.              <xsl:for-each select="media/object/children/object/children/object">
  456.                 <xsl:sort select="attrib/*[name()=$sort-by]" />
  457.                 <td align="center"><a target="main" href="{$html-file-prefix}{attrib/name}.html"><img class="thumb" width="{attrib/thumb-x-size}" height="{attrib/thumb-y-size}" src="{attrib/thumb-path}/{attrib/thumb-name}" border="0" /></a></td>
  458.             </xsl:for-each>
  459.             </tr>
  460.             <tr>
  461.                <xsl:for-each select="media/object/children/object/children/object">
  462.                 <xsl:sort select="attrib/*[name()=$sort-by]" />
  463.                 <td align="center"><a target="main" href="{$html-file-prefix}{attrib/name}.html"><xsl:value-of select="galleroo:image-title(attrib)" /></a></td>
  464.               </xsl:for-each>
  465.             </tr>
  466.             </table>
  467.         </div>   
  468.     </xsl:otherwise>
  469.     </xsl:choose> 
  470.     
  471.     </body>
  472.     </html>
  473.             
  474.     <!-- cutter output -->
  475.     <xsl:text> </xsl:text>
  476.     <xsl:comment>CUTHERE: <xsl:value-of select="galleroo:rplstr($html-file-prefix, '-', '\-')" />nav.html ?</xsl:comment>
  477.     <xsl:text> </xsl:text>
  478.  
  479. </xsl:template>    
  480.  
  481. <!-- emit ye standard blank slide -->
  482. <xsl:template name="gal-emit-blank-slide">
  483.     <xsl:param name="title" />
  484.     <xsl:param name="sub-title" />
  485.     <xsl:param name="css-name" />
  486.     <xsl:param name="custom-css-file" />
  487.     <xsl:param name="html-file-prefix" />
  488.  
  489.     <html>
  490.     <head>
  491.         <link type="text/css" rel="stylesheet" href="{$html-file-prefix}{$css-name}.css" />
  492.         <xsl:if test="string-length($custom-css-file) != 0">
  493.             <link type="text/css" rel="stylesheet" href="{$custom-css-file}" />
  494.         </xsl:if>    
  495.         <title><xsl:value-of select="$title" /> - <xsl:value-of select="$sub-title" /></title>
  496.     </head>
  497.     <body class="slide-page">
  498.         <!-- title -->
  499.         <div align="center"><h1><xsl:value-of select="$title" /> - <xsl:value-of select="$sub-title" /></h1></div>
  500.     </body>
  501.     </html>
  502.     
  503.     <!-- cutter output -->
  504.     <xsl:text> </xsl:text>
  505.     <xsl:comment>CUTHERE: <xsl:value-of select="galleroo:rplstr($html-file-prefix, '-', '\-')" />blank.html ?</xsl:comment>
  506.     <xsl:text> </xsl:text>
  507.  
  508. </xsl:template> 
  509.  
  510. <!-- emit ye simple slide pages -->
  511. <xsl:template name="gal-emit-simple-slides">
  512.     <xsl:param name="pix" />
  513.     <xsl:param name="title" />
  514.     <xsl:param name="sub-title" />
  515.     <xsl:param name="css-name" />
  516.     <xsl:param name="custom-css-file" />
  517.     <xsl:param name="do-auto-play-movies" />
  518.     <xsl:param name="html-file-prefix" />
  519.     
  520.     <xsl:for-each select="$pix">
  521.         <html>
  522.             <xsl:comment> Transformed from XML with Galleroo XSL stylesheet 1.0</xsl:comment>
  523.             <xsl:comment> Source path='<xsl:value-of select="$source-root/list/media/basepath" />' </xsl:comment>
  524.         <head>
  525.             <link type="text/css" rel="stylesheet" href="{$html-file-prefix}{$css-name}.css" />
  526.             <xsl:if test="string-length($custom-css-file) != 0">
  527.                 <link type="text/css" rel="stylesheet" href="{$custom-css-file}" />
  528.             </xsl:if>    
  529.             <title><xsl:value-of select="galleroo:image-title(attrib)" /><xsl:value-of select="galleroo:image-caption(attrib)" /></title>
  530.         </head>
  531.         <body class="slide-page">
  532.             <!-- title -->
  533.             <div align="center"><h1><xsl:value-of select="$title" />  - <xsl:value-of select="$sub-title" /></h1></div>
  534.             
  535.             <!-- subtitle -->
  536.             <div align="center"><h3><xsl:value-of select="galleroo:image-title(attrib)" /><xsl:value-of select="galleroo:image-caption(attrib)" /></h3></div>
  537.                         
  538.             <!-- image -->
  539.             <xsl:call-template name="gal-emit-image">
  540.                 <xsl:with-param name="do-auto-play-movies" select="$do-auto-play-movies" />
  541.             </xsl:call-template>
  542.  
  543.               <!-- comment -->
  544.             <div style="text-align:center; margin-left:auto; margin-right:auto; align:center; width:50%; padding:1em;">
  545.                 <xsl:value-of select="galleroo:image-comment(attrib)" />
  546.             </div> 
  547.  
  548.             <!-- lister signature -->
  549.               <xsl:call-template name="gal-emit-signature" />
  550.         </body>
  551.         </html>
  552.  
  553.         <!-- cutter output -->
  554.         <xsl:text> </xsl:text>
  555.         <xsl:comment>CUTHERE: <xsl:value-of select="galleroo:rplstr(concat($html-file-prefix, attrib/name), '-', '\-')" />.html ?</xsl:comment>
  556.         <xsl:text> </xsl:text>
  557.  
  558.     </xsl:for-each>    
  559. </xsl:template>
  560.  
  561. <!-- simple, standard image/video output -->
  562. <xsl:template name="gal-emit-image">
  563.     <xsl:param name="do-auto-play-movies" />
  564.     
  565.     <!-- the full size image/video -->
  566.     
  567.     <xsl:choose>
  568.     <!-- video -->
  569.         <xsl:when test="attrib/format = 'video'">
  570.         <div align="center">
  571.             <embed class="slide" src="{attrib/full-path}/{attrib/name}" mute="0" enablecontextmenu="1" showdisplay="0" autostart="{$do-auto-play-movies = 'yes'}" playcount="1" showcontrols="1" />
  572.         </div>
  573.         <div align="center">
  574.         <!--
  575.             commented out pretty number output until xsltproc is fixed.
  576.             <a href="{attrib/full-path}/{attrib/name}"><xsl:value-of select="galleroo:pretty-name(attrib/name)" /> (<xsl:number value="attrib/file-size div 1024" grouping-separator="," grouping-size="3" />KB)</a>
  577.         -->
  578.             <a href="{attrib/full-path}/{attrib/name}"><xsl:value-of select="galleroo:pretty-name(attrib/name)" /> (<xsl:number value="attrib/file-size" /> Bytes)</a>
  579.  
  580.         </div> 
  581.         </xsl:when>
  582.     <!-- image -->
  583.         <xsl:otherwise>
  584.         <div align="center">
  585.             <img class="slide" src="{attrib/full-path}/{attrib/name}" border="0" />
  586.         </div>
  587.         </xsl:otherwise>
  588.     </xsl:choose>
  589. </xsl:template>
  590.  
  591. <!-- emit the wonderful Galleroo signature with a link back to www.xyster.net -->
  592. <xsl:template name="gal-emit-signature">
  593. <div>Generated by <a href="http://www.xyster.net"><xsl:value-of select="$source-root/list/generator" /></a></div>
  594. </xsl:template>
  595.  
  596. <!-- In order to split the final HTML page, we emit file 'cutting' directives. 
  597.      The directive format is "CUTHERE: <file name> ?". Note that there is exactly
  598.      one space before and after the file name and that because XML/XSL is braindead 
  599.      we have to escape double dashes (what were they thinking!?).
  600. -->
  601.  
  602. <!-- cutter index page output -->
  603. <xsl:template name="gal-emit-cutter-index">
  604.     <xsl:param name="index" />
  605.     <xsl:param name="html-file-prefix" />
  606.     <xsl:text> </xsl:text>
  607.     <xsl:comment>CUTHERE: <xsl:value-of select="galleroo:rplstr(concat($html-file-prefix, galleroo:index-html-name($index)), '-', '\-')" /> ?</xsl:comment>
  608.     <xsl:text> </xsl:text>
  609. </xsl:template>
  610.  
  611. <!-- cutter slide page output -->
  612. <xsl:template name="gal-emit-cutter-slide">
  613.     <xsl:param name="html-file-prefix" />
  614.     <xsl:text> </xsl:text>
  615.     <xsl:comment>CUTHERE: <xsl:value-of select="galleroo:rplstr(concat($html-file-prefix, attrib/name), '-', '\-')" />.html ?</xsl:comment>
  616.     <xsl:text> </xsl:text>
  617. </xsl:template>
  618.  
  619. <!-- creates a horizontal thumbnail slider. Must be in a table -->
  620. <xsl:template name="gal-emit-horizontal-thumb-slider">
  621.     <xsl:param name="html-file-prefix" />
  622.     <xsl:param name="thumb-size" />
  623.     <xsl:param name="parent-index" />
  624.     <xsl:param name="index-last" />
  625.     <tr>
  626.         <td align="center" width="{$thumb-size}" height="{$thumb-size}">
  627.             <xsl:if test="position() > 2 or $parent-index != 1">
  628.             <a href="{$html-file-prefix}{preceding-sibling::object[position() = 2]/attrib/name}.html"><img class="thumb" width="{preceding-sibling::object[position() = 2]/attrib/thumb-x-size}" height="{preceding-sibling::object[position() = 2]/attrib/thumb-y-size}" src="{preceding-sibling::object[position() = 2]/attrib/thumb-path}/{preceding-sibling::object[position() = 2]/attrib/thumb-name}" border="0" /></a>
  629.         </xsl:if>                    
  630.         </td>
  631.         <td align="center" width="{$thumb-size}" height="{$thumb-size}">
  632.             <xsl:if test="position() > 1 or $parent-index != 1">
  633.             <a href="{$html-file-prefix}{preceding-sibling::object[position() = 1]/attrib/name}.html"><img class="thumb" width="{preceding-sibling::object[position() = 1]/attrib/thumb-x-size}" height="{preceding-sibling::object[position() = 1]/attrib/thumb-y-size}" src="{preceding-sibling::object[position() = 1]/attrib/thumb-path}/{preceding-sibling::object[position() = 1]/attrib/thumb-name}" border="0" /></a>
  634.             </xsl:if>
  635.         </td>
  636.         <td align="center" width="{$thumb-size}" height="{$thumb-size}">
  637.             <img class="thumb" width="{attrib/thumb-x-size}" height="{attrib/thumb-y-size}" src="{attrib/thumb-path}/{attrib/thumb-name}" border="0" />
  638.         </td>
  639.         <td align="center" width="{$thumb-size}" height="{$thumb-size}">
  640.             <xsl:if test="position() < last() or $parent-index != $index-last">
  641.             <a href="{$html-file-prefix}{following-sibling::object[position() = 1]/attrib/name}.html"><img class="thumb" width="{following-sibling::object[position() = 1]/attrib/thumb-x-size}" height="{following-sibling::object[position() = 1]/attrib/thumb-y-size}" src="{following-sibling::object[position() = 1]/attrib/thumb-path}/{following-sibling::object[position() = 1]/attrib/thumb-name}" border="0" /></a>
  642.             </xsl:if>
  643.         </td>
  644.         <td align="center" width="{$thumb-size}" height="{$thumb-size}">
  645.             <xsl:if test="position() < last() - 1 or $parent-index != $index-last">
  646.             <a href="{$html-file-prefix}{following-sibling::object[position() = 2]/attrib/name}.html"><img class="thumb" width="{following-sibling::object[position() = 2]/attrib/thumb-x-size}" height="{following-sibling::object[position() = 2]/attrib/thumb-y-size}" src="{following-sibling::object[position() = 2]/attrib/thumb-path}/{following-sibling::object[position() = 2]/attrib/thumb-name}" border="0" /></a>
  647.             </xsl:if>
  648.         </td>
  649.     </tr>
  650. </xsl:template>
  651.  
  652. <!-- creates a vertical thumbnail slider. Must be in a table -->
  653. <xsl:template name="gal-emit-vertical-thumb-slider">
  654.     <xsl:param name="html-file-prefix" />
  655.     <xsl:param name="thumb-size" />
  656.     <xsl:param name="parent-index" />
  657.     <xsl:param name="index-last" />
  658.     <tr>
  659.         <td align="center" width="{$thumb-size}" height="{$thumb-size}">
  660.             <xsl:if test="position() > 2 or $parent-index != 1">
  661.             <a href="{$html-file-prefix}{preceding-sibling::object[position() = 2]/attrib/name}.html"><img class="thumb" width="{preceding-sibling::object[position() = 2]/attrib/thumb-x-size}" height="{preceding-sibling::object[position() = 2]/attrib/thumb-y-size}" src="{preceding-sibling::object[position() = 2]/attrib/thumb-path}/{preceding-sibling::object[position() = 2]/attrib/thumb-name}" border="0" /></a>
  662.         </xsl:if>                    
  663.         </td>
  664.     </tr>
  665.     <tr>    
  666.         <td align="center" width="{$thumb-size}" height="{$thumb-size}">
  667.             <xsl:if test="position() > 1 or $parent-index != 1">
  668.             <a href="{$html-file-prefix}{preceding-sibling::object[position() = 1]/attrib/name}.html"><img class="thumb" width="{preceding-sibling::object[position() = 1]/attrib/thumb-x-size}" height="{preceding-sibling::object[position() = 1]/attrib/thumb-y-size}" src="{preceding-sibling::object[position() = 1]/attrib/thumb-path}/{preceding-sibling::object[position() = 1]/attrib/thumb-name}" border="0" /></a>
  669.             </xsl:if>
  670.         </td>
  671.     </tr>
  672.     <tr>    
  673.         <td align="center" width="{$thumb-size}" height="{$thumb-size}">
  674.             <img class="thumb" width="{attrib/thumb-x-size}" height="{attrib/thumb-y-size}" src="{attrib/thumb-path}/{attrib/thumb-name}" border="0" />
  675.         </td>
  676.     </tr>
  677.     <tr>    
  678.         <td align="center" width="{$thumb-size}" height="{$thumb-size}">
  679.             <xsl:if test="position() < last() or $parent-index != $index-last">
  680.             <a href="{$html-file-prefix}{following-sibling::object[position() = 1]/attrib/name}.html"><img class="thumb" width="{following-sibling::object[position() = 1]/attrib/thumb-x-size}" height="{following-sibling::object[position() = 1]/attrib/thumb-y-size}" src="{following-sibling::object[position() = 1]/attrib/thumb-path}/{following-sibling::object[position() = 1]/attrib/thumb-name}" border="0" /></a>
  681.             </xsl:if>
  682.         </td>
  683.     </tr>
  684.     <tr>    
  685.         <td align="center" width="{$thumb-size}" height="{$thumb-size}">
  686.             <xsl:if test="position() < last() - 1 or $parent-index != $index-last">
  687.             <a href="{$html-file-prefix}{following-sibling::object[position() = 2]/attrib/name}.html"><img class="thumb" width="{following-sibling::object[position() = 2]/attrib/thumb-x-size}" height="{following-sibling::object[position() = 2]/attrib/thumb-y-size}" src="{following-sibling::object[position() = 2]/attrib/thumb-path}/{following-sibling::object[position() = 2]/attrib/thumb-name}" border="0" /></a>
  688.             </xsl:if>
  689.         </td>
  690.     </tr>
  691. </xsl:template>
  692.  
  693. <xsl:template name="gal-emit-exposure">
  694.     <xsl:variable name="exposure" select="attrib/exposure-time" />
  695.     <xsl:choose>
  696.         <!-- XXX there has to be a better way to figure out if something is undefined... -->
  697.         <xsl:when test="string(number($exposure)) = 'NaN' or $exposure = 0.0 or $exposure = ''" />
  698.         <xsl:when test="$exposure >= 1.0 or $exposure <= 0.0">
  699.             Exposure: <xsl:value-of select="$exposure" />"
  700.         </xsl:when>
  701.         <xsl:otherwise>
  702.             Exposure: 1/<xsl:value-of select="round(1.0 div $exposure)" />
  703.         </xsl:otherwise>
  704.     </xsl:choose>
  705. </xsl:template>
  706.  
  707. <xsl:template name="gal-emit-f-stop">
  708.     <xsl:variable name="f-stop" select="attrib/f-stop" />
  709.     <xsl:choose>
  710.         <!-- XXX there has to be a better way to figure out if something is undefined... -->
  711.         <xsl:when test="string(number($f-stop)) = 'NaN' or $f-stop = 0.0 or $f-stop = ''" />
  712.         <xsl:otherwise>
  713.              F/Stop: <xsl:value-of select="$f-stop" />
  714.         </xsl:otherwise>
  715.     </xsl:choose>
  716. </xsl:template>
  717.  
  718. <xsl:template name="gal-emit-focal-distance">
  719.     <xsl:variable name="focal-distance" select="attrib/focal-distance" />
  720.    
  721.     <xsl:choose>
  722.         <!-- XXX there has to be a better way to figure out if something is undefined... -->
  723.         <xsl:when test="string(number($focal-distance)) = 'NaN' or $focal-distance = 0.0 or $focal-distance = ''" />
  724.         <xsl:otherwise>
  725.             Focal Distance: <xsl:value-of select="$focal-distance" />m
  726.         </xsl:otherwise>
  727.     </xsl:choose>
  728. </xsl:template>
  729.  
  730. <xsl:template name="gal-emit-flash-used">
  731.     <xsl:variable name="used" select="attrib/flash-used" />
  732.  
  733.     <xsl:choose>
  734.         <!-- XXX there has to be a better way to figure out if something is undefined... -->
  735.         <xsl:when test="string(number($used)) = 'NaN' or $used = ''" />
  736.         <xsl:when test="$used = 1">
  737.             Flash: Used    
  738.         </xsl:when>
  739.         <xsl:otherwise>
  740.             Flash: Not used
  741.         </xsl:otherwise>
  742.     </xsl:choose>
  743. </xsl:template>
  744.  
  745. <xsl:template name="gal-emit-is-color">
  746.     <xsl:variable name="color" select="attrib/is-color" />
  747.     
  748.     <xsl:choose>
  749.         <xsl:when test="string(number($color)) = 'NaN'" />
  750.         <xsl:when test="$color = 1">
  751.             Mode: Color
  752.         </xsl:when>
  753.         <xsl:otherwise>
  754.             Mode: Black & White
  755.         </xsl:otherwise>
  756.     </xsl:choose>
  757. </xsl:template>
  758.  
  759. <xsl:template name="gal-emit-ccd-width">
  760.     <xsl:variable name="ccd-width" select="attrib/ccd-width" />
  761.     
  762.     <xsl:choose>
  763.         <!-- XXX there has to be a better way to figure out if something is undefined... -->
  764.         <xsl:when test="string(number($ccd-width)) = 'NaN' or $ccd-width = 0.0 or $ccd-width = ''" />
  765.         <xsl:when test="$ccd-width = 0.0 or $ccd-width = ''" />
  766.         <xsl:otherwise>
  767.             CCD Width: <xsl:value-of select="attrib/ccd-width" />mm
  768.         </xsl:otherwise>
  769.     </xsl:choose>
  770. </xsl:template>
  771.  
  772. <xsl:template name="gal-emit-exif-version">
  773.     <xsl:variable name="exif-version" select="attrib/exif-version" />
  774.  
  775.     <xsl:choose>
  776.         <!-- XXX there has to be a better way to figure out if something is undefined... -->
  777.         <xsl:when test="string(number($exif-version)) = 'NaN' or $exif-version = 0.0 or $exif-version = ''" />
  778.         <xsl:otherwise>
  779.              EXIF Version: <xsl:value-of select="$exif-version" />
  780.         </xsl:otherwise>
  781.     </xsl:choose>
  782. </xsl:template>
  783.  
  784. <xsl:template name="gal-emit-name-value-string">
  785.     <xsl:param name="name" />
  786.     <xsl:param name="value" />
  787.     
  788.     <xsl:choose>
  789.         <xsl:when test="string-length($value) = 0" />
  790.         <xsl:otherwise>
  791.             <xsl:value-of select="$name" /><xsl:value-of select="$value" />
  792.         </xsl:otherwise>
  793.     </xsl:choose>
  794. </xsl:template>
  795.  
  796. <xsl:template name="gal-rplstr">
  797.     <xsl:param name="value" />
  798.     <xsl:param name="from" />
  799.     <xsl:param name="to" />
  800.  
  801.     <xsl:choose>
  802.         <xsl:when test="contains($value, $from)">
  803.             <xsl:value-of select="substring-before($value, $from)" />
  804.             <xsl:value-of select="$to" />
  805.             <xsl:call-template name="gal-rplstr">
  806.                 <xsl:with-param name="value" select="substring-after($value, $from)" />
  807.                 <xsl:with-param name="from" select="$from" />
  808.                 <xsl:with-param name="to" select="$to" />
  809.             </xsl:call-template>
  810.        </xsl:when>
  811.        <xsl:otherwise>
  812.             <xsl:value-of select="$value" />
  813.        </xsl:otherwise>
  814.     </xsl:choose>
  815. </xsl:template>
  816.                 
  817. </xsl:stylesheet>